package com.gsafety.library.Base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.gsafety.library.Widgets.ProgressDia;

public abstract class IBaseActivity extends AppCompatActivity {
    private ProgressDia mProgressDia;

    @Override
    protected void onCreate(@Nullable final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        initView();
        initData();
    }

    public abstract void initView();

    public abstract void initData();

    public abstract int getLayoutId();


    public void showDia(String msg) {
        if (mProgressDia == null) {
            mProgressDia = new ProgressDia(this);
        }
        mProgressDia.show();
        mProgressDia.setCancelable(true);
        if (msg != null && !msg.isEmpty()) {
            mProgressDia.setTitleText(msg);
        } else {
            mProgressDia.setTitleText("加载中....");
        }
    }


    public void disDia() {
        if (mProgressDia.isShowing()) {
            mProgressDia.dismiss();

        }
    }
}
